Telegram Group & Telegram Channel
Напишите линейную регрессию на Python с нуля

Это один из самых простых алгоритмов. Он включает следующие шаги:
1️⃣ Инициализация параметров.
2️⃣ Вычисление предсказаний.
3️⃣ Вычисление функции потерь.
4️⃣ Обновление параметров с помощью градиентного спуска.
5️⃣ Повторение до сходимости.
import numpy as np

class LinearRegression:
def __init__(self, learning_rate=0.01, n_iters=1000):
self.learning_rate = learning_rate
self.n_iters = n_iters

def fit(self, X, y):
n_samples, n_features = X.shape
self.weights = np.zeros(n_features)
self.bias = 0

for _ in range(self.n_iters):
model_preds = self.predict(X)
dw = (1 / n_samples) * np.dot(X.T, (model_preds - y))
db = (1 / n_samples) * np.sum(model_preds - y)

self.weights -= self.learning_rate * dw
self.bias -= self.learning_rate * db

def predict(self, X):
return np.dot(X, self.weights) + self.bias


#машинное_обучение
#программирование
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/ds_interview_lib/273
Create:
Last Update:

Напишите линейную регрессию на Python с нуля

Это один из самых простых алгоритмов. Он включает следующие шаги:
1️⃣ Инициализация параметров.
2️⃣ Вычисление предсказаний.
3️⃣ Вычисление функции потерь.
4️⃣ Обновление параметров с помощью градиентного спуска.
5️⃣ Повторение до сходимости.

import numpy as np

class LinearRegression:
def __init__(self, learning_rate=0.01, n_iters=1000):
self.learning_rate = learning_rate
self.n_iters = n_iters

def fit(self, X, y):
n_samples, n_features = X.shape
self.weights = np.zeros(n_features)
self.bias = 0

for _ in range(self.n_iters):
model_preds = self.predict(X)
dw = (1 / n_samples) * np.dot(X.T, (model_preds - y))
db = (1 / n_samples) * np.sum(model_preds - y)

self.weights -= self.learning_rate * dw
self.bias -= self.learning_rate * db

def predict(self, X):
return np.dot(X, self.weights) + self.bias


#машинное_обучение
#программирование

BY Библиотека собеса по Data Science | вопросы с собеседований


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/ds_interview_lib/273

View MORE
Open in Telegram


Библиотека собеса по Data Science | вопросы с собеседований Telegram | DID YOU KNOW?

Date: |

The global forecast for the Asian markets is murky following recent volatility, with crude oil prices providing support in what has been an otherwise tough month. The European markets were down and the U.S. bourses were mixed and flat and the Asian markets figure to split the difference.The TSE finished modestly lower on Friday following losses from the financial shares and property stocks.For the day, the index sank 15.09 points or 0.49 percent to finish at 3,061.35 after trading between 3,057.84 and 3,089.78. Volume was 1.39 billion shares worth 1.30 billion Singapore dollars. There were 285 decliners and 184 gainers.

Telegram Gives Up On Crypto Blockchain Project

Durov said on his Telegram channel today that the two and a half year blockchain and crypto project has been put to sleep. Ironically, after leaving Russia because the government wanted his encryption keys to his social media firm, Durov’s cryptocurrency idea lost steam because of a U.S. court. “The technology we created allowed for an open, free, decentralized exchange of value and ideas. TON had the potential to revolutionize how people store and transfer funds and information,” he wrote on his channel. “Unfortunately, a U.S. court stopped TON from happening.”

Библиотека собеса по Data Science | вопросы с собеседований from id


Telegram Библиотека собеса по Data Science | вопросы с собеседований
FROM USA